package com.yan.test.test3;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author taoge
 * @Date 2024/8/8 19:12
 * @Description
 */
public class MyTask3 implements Runnable{
    Lock lock = new ReentrantLock();
    int i = 1;
    @Override
    public void run() {
        lock.lock();
        try {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "第"+ i +"个通过隧道");
            i++;
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }
}
